package datastructures;

import java.io.Serializable;

/**
 * A World contains all game data
 * @author Administrator
 *
 */
public class World implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7707279676953323643L;
	
	private int height;
	private int width;
	private Window[][] windows;

	/**
	 * Default constructor that creates a world with the dimensions 5,5
	 */
	public World() {
		this(5,5);
	}

	/**
	 * Constructor creating a world with the dimensions width and height
	 * @param width
	 * @param height
	 */
	public World(int width, int height) {
		this.height = height;
		this.width = width;
		this.windows = new Window[width][height];
		for(int x =0; x < width;x++){
			for(int y = 0; y<height;y++){
				Coordinate newCordinate = new Coordinate(x,y);
				this.windows[x][y] = new Window(newCordinate);
			}
		}
	}

	/**
	 * Returns the height of this world
	 * @return the height of this world
	 */
	public int getHeight() {
		return this.height;
	}

	/**
	 * returns the width of this world
	 * @return the width of this world
	 */
	public int getWidth() {
		return this.width;
	}

	/**
	 * Adds or replace a window at x,y
	 * @param w the window to add
	 * @param c coordinates for window
	 */
	public void addOrReplaceWindow(Window w,Coordinate c) {
		this.windows[c.getX()][c.getY()] = w;
	}
	
	/**
	 * Returns a window at Coordinates c
	 * @param c
	 * @return the window at coordinates c
	 */
	public Window getWindow(Coordinate c){
		return this.windows[c.getX()][c.getY()];
	}

}
